var app = getApp()
var UserID 
var util = require('../../utils/util.js');
var startTime
var endTime
Page({
  data: {
  //  array:['aaa','bbb']

  },
  onLoad: function (options) {
    var that = this;
    UserID = app.globalData.UserID;
    wx.request({
      url: 'https://ke.slickghost.com/dk/chooseActivity.php',
      data:{
        UserID:UserID
      },
      headers: {
        'Content-Type': 'application/json'
      },
      success: function (res) {
        //将获取到的json数据，存在名字叫array的这个数组中
        console.log(res.data);
        that.setData({
          array: res.data

        })
      }
    })


  },
  radioChange: function (e) {

    var id = e.detail.value;
    wx.request({
      url: 'https://ke.slickghost.com/dk/getTime.php',
      data: {
        id: id
      },
      success: function (res) {
        console.log(res.data);
        startTime = res.data[0].StartTime;
        endTime = res.data[0].EndTime;
        var time = util.formatTime(new Date());
        if (time < startTime) {
          wx.showModal({
            title: '活动未开始',
            content: '活动开始时间：' + startTime,
          })

        }
        else if (time > endTime) {
          wx.showModal({
            title: '活动已结束',
            content: '活动结束时间：' + endTime,
          })
        }
        else {

          wx.navigateTo({
            url: '../release/release?dataid=' + id

          })
        }
      }

    })


  }

})













